package gdkm.wsz.dao;

import gdkm.wsz.pojo.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrderDAO {
    @Select("select * from tb_order where id = #{id}")
    @Results(id = "orderMAP", value = {
            @Result(property = "user", column = "user_id",
                    one = @One(select = "gdkm.wsz.dao.UserDAO.findById"))
    })
    public Order findById(Integer id);
    @ResultMap("orderMAP")
    @Select("select * from tb_order")
    public List<Order> findAll();
    @Insert("insert into tb_order values(null,#{number},#{user.id})")
    public boolean save(Order order);
    @Update("update tb_order set number = #{number},user_id = #{user.id} where id = #{id}")
    public boolean update(Order order);
    @Delete("delete from tb_order where id = #{id}")
    public boolean delete(Order order);
    @Select("select * from tb_order where user_id = #{userId}")
    public List<Order> findByUserId(Integer userId);
}
